/*
 * Author: Ray (qray686898@163.com)
 */
import { getToken, setToken, removeToken } from '@/util/auth'
import url from '@/const/apiURL'
import request from '@/router/axios'

export const loginByUsername = (loginName, password, imageCode, appKey) => {
    return request({
        url: url.LOGIN_BY_REG,
        method: 'post',
        data: { loginName, password, imageCode, appKey }
    })
}

export function mobileLogin (phone, code) {
    return request({
        url: url.LOGIN_BY_PHONE,
        method: 'post',
        data: { phone, code }
    })
}

export function getAuth (appKey) {
    return request({
        url: url.AUTH_URL,
        method: 'post',
        data: { appKey }
    })
}


export const logout = () => {
    return request({
        url: url.LOGOUT_URL,
        method: 'post',
        data: { 'key': 'key' }
    })
}

export function register (data) {
    return request({
        url: url.REG_URL,
        method: 'post',
        data
    })
}

export function validMsg (data) {
    return request({
        url: url.VALID_MSG_URL,
        method: 'GET',
        params: data
    })
}

export function forgetPassword (data) {
    return request({
        url: url.FORGET_PASSWORD_URL,
        method: 'post',
        data
    })
}

export function getImaceCode () {
    return request({
        url: url.IMAGE_CODE_URL,
        method: 'post',
        data: { 'key': 'key' }
    })
}